package com.lebang.service;

import com.alibaba.fastjson.JSON;
import com.lebang.domain.AppCloseMsg;
import com.lebang.example.AppCloseMsgExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 应用退出说明
* @Author hwq
* @Date 2020-01-13
*/
@Service
public class AppCloseMsgService extends BaseService<AppCloseMsg, Long, AppCloseMsgExample>{

    @Autowired
    private RedisCacheService redisCacheService;
    private static final String KEY="AppCloseMsg";
    /**
     * 获取全部数据
     *
     * @return
     */
    public List<AppCloseMsg> findAllList() {
        List<AppCloseMsg> appEatConfigs = redisCacheService.selectListByKey(KEY, AppCloseMsg.class);
        if (appEatConfigs == null) {
            AppCloseMsgExample example = new AppCloseMsgExample();
            example.createCriteria().andHasDeletedEqualTo(0);
            appEatConfigs = this.selectByExample(example);
            if (appEatConfigs != null) {
                redisCacheService.addCacheListByKey(KEY, JSON.toJSONString(appEatConfigs));
            }
        }
        return appEatConfigs;
    }

    public void delCacheListByKey(){
        redisCacheService.delCache(KEY);
    }
}
